package com.acsior.hibernate.vo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.acsior.dac.impl.hibernate.vo.GeneratorKey;
import com.acsior.dac.impl.hibernate.vo.HibernatePersistantIntegerIdVO;

/**
 * Клас, който обслужва
 * 
 * @author <d.kolev@acsior.com>
 */
@Entity
@Table(name = "attribute_groups_nom_additional_attributes")
@GeneratorKey(tableName = "attribute_groups_nom_additional_attributes")
public class BuildingAttributeVO extends HibernatePersistantIntegerIdVO {

	/** */
	private static final long serialVersionUID = -274077779870318507L;

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "buildingAttribute")
	private List<AttributeOptionVO> buildingAttributeOptions;

	@Column(name = "is_required", nullable = false)
	private boolean isRequired;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "nom_additional_attribute_id", nullable = false)
	private NomAdditionalAttributeVO nomAdditionalAttibute;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "nom_attribute_type_id", nullable = false)
	private NomAttributeTypeVO nomAttributeType;

	@Column(name = "ordering", nullable = false)
	private Integer ordering;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "postal_service_id", nullable = false)
	private PostalServiceVO postalService;

	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name = "attribute_group_id", nullable = false)
	private AttributeGroupVO postalServiceGroup;

	/** Конструктор */
	public BuildingAttributeVO() {
		this.buildingAttributeOptions = new ArrayList<AttributeOptionVO>();
	}

	/**
	 * @return the buildingAttributeOptions
	 */
	public List<AttributeOptionVO> getBuildingAttributeOptions() {
		return this.buildingAttributeOptions;
	}

	/**
	 * @return the nomAdditionalAttibute
	 */
	public NomAdditionalAttributeVO getNomAdditionalAttibute() {
		return this.nomAdditionalAttibute;
	}

	/**
	 * @return the nomAttributeType
	 */
	public NomAttributeTypeVO getNomAttributeType() {
		return this.nomAttributeType;
	}

	/**
	 * @return the ordering
	 */
	public Integer getOrdering() {
		return this.ordering;
	}

	/**
	 * @return the postalService
	 */
	public AttributeGroupVO getPostalAttributeGroup() {
		return this.postalServiceGroup;
	}

	/**
	 * @return the postalService
	 */
	public PostalServiceVO getPostalService() {
		return this.postalService;
	}

	/**
	 * @return the isRequired
	 */
	public boolean isRequired() {
		return this.isRequired;
	}

	/**
	 * @param buildingAttributeOptions
	 *            the buildingAttributeOptions to set
	 */
	public void setBuildingAttributeOptions(List<AttributeOptionVO> buildingAttributeOptions) {
		this.buildingAttributeOptions = buildingAttributeOptions;
	}

	/**
	 * @param nomAdditionalAttibute
	 *            the nomAdditionalAttibute to set
	 */
	public void setNomAdditionalAttibute(NomAdditionalAttributeVO nomAdditionalAttibute) {
		this.nomAdditionalAttibute = nomAdditionalAttibute;
	}

	/**
	 * @param nomAttributeType
	 *            the nomAttributeType to set
	 */
	public void setNomAttributeType(NomAttributeTypeVO nomAttributeType) {
		this.nomAttributeType = nomAttributeType;
	}

	/**
	 * @param ordering
	 *            the ordering to set
	 */
	public void setOrdering(Integer ordering) {
		this.ordering = ordering;
	}

	/**
	 * @param postalServiceGroup
	 *            the postalService to set
	 */
	public void setPostalAttributeGroup(AttributeGroupVO postalServiceGroup) {
		this.postalServiceGroup = postalServiceGroup;
	}

	/**
	 * @param postalService
	 *            the postalService to set
	 */
	public void setPostalService(PostalServiceVO postalService) {
		this.postalService = postalService;
	}

	/**
	 * @param isRequired
	 *            the isRequired to set
	 */
	public void setRequired(boolean isRequired) {
		this.isRequired = isRequired;
	}

}
